package com.ultimatech.feign.service.impl;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ultimatech.cloud.poc.base.model.Message;
import com.ultimatech.cloud.poc.base.model.TestData;
import com.ultimatech.cloud.poc.base.model.UserVo;
import com.ultimatech.feign.service.ISchedualServiceHi;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * Created by zhangleping on 2017/10/13.
 */
@Component
public class SchedualServiceHiImpl implements ISchedualServiceHi {

    private Gson gson=new GsonBuilder().create();

    public String sayHiFromClientOne(@RequestParam(value = "name") String name) {
        return "Sorry, errors! " + name;
    }

    public String whoami(@RequestParam(value = "name") String name) {
        return "Sorry, errors! " + name;
    }

    public TestData test(@RequestParam(value = "name") String name) {
        TestData data = new TestData();
        data.setName("errors !");
        return data;
    }

    public Message<UserVo> createUser(UserVo user) {
        Message<UserVo> message=new Message<UserVo>();
        message.setData(user);
        message.setStatus("failed");
        message.setError("Sorry, errors! Create failed! ");
        return message;
    }

    public Message<Integer> delUser(Integer userId) {
        Message<Integer> message=new Message<Integer>();
        message.setData(userId);
        message.setStatus("failed");
        message.setError("Sorry, errors! Delete failed! ");
        return message;
    }

    public Message<UserVo> updateUser(UserVo user) {
        Message<UserVo> message=new Message<UserVo>();
        message.setData(user);
        message.setStatus("failed");
        message.setError("Sorry, errors! Update failed! ");
        return message;
    }

    public Message<UserVo> getUserById(Integer id) {
        Message<UserVo> message=new Message<UserVo>();
        message.setData(null);
        message.setStatus("failed");
        message.setError("Sorry, errors! Get by Id failed! ");
        return message;
    }

    public Message<List<UserVo>> findAllUser() {
        Message<List<UserVo>> message=new Message<List<UserVo>>();
        message.setData(null);
        message.setStatus("failed");
        message.setError("Sorry, errors! Find all user failed! ");
        return message;
    }
}
